package com.lineage.data.quest;

import com.lineage.data.executor.QuestExecutor;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_NPCTalkReturn;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.templates.L1Quest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Chapter02 extends QuestExecutor {
  private static final Log _log = LogFactory.getLog(Chapter02.class);
  
  public static L1Quest QUEST;
  
  public static final int MAPID = 9101;
  
  private static final String _html = "q_cha1_1";
  
  public static QuestExecutor get() {
    return new Chapter02();
  }
  
  public void execute(L1Quest quest) {
    try {
      QUEST = quest;
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } 
  }
  
  public void startQuest(L1PcInstance pc) {
    try {
      if (QUEST.check(pc)) {
        if (pc.getLevel() < QUEST.get_questlevel())
          pc.sendPackets((ServerBasePacket)new S_NPCTalkReturn(pc.getId(), "y_q_not1")); 
      } else {
        pc.sendPackets((ServerBasePacket)new S_NPCTalkReturn(pc.getId(), "y_q_not2"));
      } 
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } 
  }
  
  public void endQuest(L1PcInstance pc) {
    try {
      String questName = QUEST.get_questname();
      pc.sendPackets((ServerBasePacket)new S_ServerMessage("\\fT" + questName + "任务结束！"));
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } 
  }
  
  public void showQuest(L1PcInstance pc) {
    try {
      if ("q_cha1_1" != null)
        pc.sendPackets((ServerBasePacket)new S_NPCTalkReturn(pc.getId(), "q_cha1_1")); 
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } 
  }
  
  public void stopQuest(L1PcInstance pc) {}
}
